---
image: /generated/articles-docs-webcodecs-buffer-writer.png
id: buffer-writer
title: bufferWriter
slug: /webcodecs/buffer-writer
crumb: '@remotion/webcodecs'
---

:::warning
[We are phasing out Remotion WebCodecs and are moving to Mediabunny](/blog/mediabunny)!
:::

import {LicenseDisclaimer} from './LicenseDisclaimer';
import {UnstableDisclaimer} from './UnstableDisclaimer';

<details>
  <summary>💼 Important License Disclaimer</summary>
  <LicenseDisclaimer />
</details>

:::warning
**Unstable API**: The writer interface is experimental. The API may change in the future.
:::

A writer for `@remotion/webcodecs` that writes to an in-memory resizable ArrayBuffer.

Can be used for [`convertMedia()`](/docs/webcodecs/convert-media) to write the converted output to memory as a buffer.

## Example

```tsx twoslash title="Using bufferWriter"
import {convertMedia} from '@remotion/webcodecs';
import {bufferWriter} from '@remotion/webcodecs/buffer';

const result = await convertMedia({
  src: 'https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4',
  container: 'webm',
  writer: bufferWriter,
});

const blob = await result.save();
```

## Memory limitations

The `bufferWriter` uses a resizable ArrayBuffer with a maximum size of 2GB. If your output file would exceed this limit, the conversion will fail.

```tsx twoslash title="Error handling for large files"
import {convertMedia} from '@remotion/webcodecs';
import {bufferWriter} from '@remotion/webcodecs/buffer';

try {
  const result = await convertMedia({
    src: 'very-large-video.mp4',
    container: 'webm',
    writer: bufferWriter,
  });
} catch (error) {
  if ((error as Error).message.includes('Could not create buffer writer')) {
    // Handle case where ArrayBuffer cannot be resized further
    console.log('File too large for buffer writer, consider using webFsWriter');
  }
}
```

## See also

- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/webcodecs/src/writers/buffer-implementation/writer.ts)
- [`webFsWriter`](/docs/webcodecs/web-fs-writer) - Alternative file system writer
- [`convertMedia()`](/docs/webcodecs/convert-media)
